﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;



using Meqs.Entity;
using Meqs.Entity.Views;
using Meqs.Logic.Interface;

namespace Meqs.Logic.Implement
{
    public class MoralityPersonCatchLogic : CommonLogic<MoralityPersonCatch, int>, IMoralityPersonCatchLogic
    {
        #region Implementation of ICommonLogic<MoralityPersonCatch, int>

        /// <sammury>
        /// 创建对象
        /// </sammury>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Create(MoralityPersonCatch entity)
        {
            return CreateObject(entity);
        }

        /// <sammury>
        /// 更新对象
        /// </sammury>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(MoralityPersonCatch entity)
        {
            return UpdateObject(entity);
        }

        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public int Delete(int entityId)
        {
            return DeleteObject(entityId);
        }

        /// <summary>
        /// 删除所有对象
        /// </summary>
        /// <returns></returns>
        public int DeleteAll()
        {
            return DeleteAllObject();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public MoralityPersonCatch FindById(int entityId)
        {
            return FindObjectById(entityId);
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount()
        {
            return FindObjectByCount();
        }

        /// <sammury>
        /// 检索对象
        /// </sammury>
        public IList<MoralityPersonCatch> FindAll()
        {
            return FindAllObject();
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount(Hashtable table)
        {
            return FindObjectByCount(table);
        }

        /// <sammury>
        /// 检索对象
        /// </sammury>
        public IList<MoralityPersonCatch> FindAll(Hashtable table)
        {
            return FindObject(table);
        }

        #endregion

        /// <summary>
        /// 插入记录
        /// </summary>
        /// <param name="mpc"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public int InsertMoralityPersonCatch(MoralityPersonCatch mpc, string schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("MoralityPersonCatch", mpc);
            ht.Add("SchoolMark", schoolMark);
            return (int)InsertCustomer("MoralityPersonCatch.InsertMoralityPersonCatch", ht);
        }

        /// <summary>
        /// 删除缓存表中对应单据及学生的记录
        /// </summary>
        /// <param name="studentID"></param>
        /// <param name="recordID"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public int DeleteMoralityPersonCatch(int studentID, int recordID, string schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("StudentID", studentID);
            ht.Add("RecordID", recordID);
            ht.Add("SchoolMark", schoolMark);
            return DeleteCustomer("MoralityPersonCatch.DeleteMoralityPersonCatch", ht);
        }

        /// <summary>
        /// 查找学期内的指定班级(年级)德育分数
        /// </summary>
        public IList<MoralityScoreInTermView> FindMoralityScoreInTerm(String schoolMark, int schoolYear, int term, int? grade, int? classId)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            ht.Add("SchoolYear", schoolYear);
            ht.Add("Term", term);
            if (grade != null)
                ht.Add("Grade", grade);
            if (classId != null)
                ht.Add("ClassID", classId);
            return FindCustomer<MoralityScoreInTermView>("MoralityPersonCatch.FindMoralityScoreInTerm", ht);
        }

        /// <summary>
        /// 查找学生的德育成绩历史
        /// </summary>
        public IList<StudentMoralityScoreView> GetMoralityHistoryReport(String schoolMark, int strID)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            ht.Add("StuID", strID);
            return FindCustomer<StudentMoralityScoreView>("MoralityPersonCatch.GetMoralityHistoryReport", ht);
        }

        public IList<StudentMoralityScoreExView> GetMoralityHistoryReportEx(String schoolMark, int strID)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            ht.Add("StuID", strID);
            return FindCustomer<StudentMoralityScoreExView>("MoralityPersonCatch.GetMoralityHistoryReportEx", ht);
        }

        public IList<MoralityPersonCatch> getCatchInfo(int ClsID, int Year, int Month, int Day, int SchoolYear, int Term, String SchoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", SchoolMark);
            ht.Add("ClsID", ClsID);
            ht.Add("Year", Year);
            ht.Add("Month", Month);
            ht.Add("Day", Day);
            ht.Add("SchoolYear", SchoolYear);
            ht.Add("Term", Term);
            return FindCustomer<MoralityPersonCatch>("MoralityPersonCatch.getCatchInfo", ht);
        }
    }
}